<?php

class IndexController extends Zend_Controller_Action {

	const ACTION_INDEX = 'index';
    private $read;
	const LOGIN_URL = '/';
    
	public function init() {
      $session = new Zend_Session_Namespace('loggin');
      if($session->user)
      {
        
        $user = UsersQuery::create()->findOneById($session->user);
        if(!$user)
        {
          $this->_redirect(self::LOGIN_URL);
        }
      }
      else 
      {
        if(self::LOGIN_URL != $this->getRequest()->getRequestUri())
        {
          $this->_redirect(self::LOGIN_URL);
        }
      }
	}

	public function indexAction() {
		$this->view->pin = $this->getRequest()->getParam('pin', null);
	}

	public function errorAction() {
		$this->_helper->layout->disableLayout();
		$this->view->result = $this->getRequest()->getParam('result');
	}

}